<?php
/**
 * Smarty plugin
 * @category VaselinEngine
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {file} function plugin
 *
 * Type:     function<br>
 * Name:     file<br>
 * Purpose:  print out a file input with additional functions to show/delete previously uploaded file. Is used by Bel_Forms_Builder
 * @author Konstantin Shamko <konstantin.shamko@gmail.com>
 * @param array parameters
 * @param Smarty
 * @return string|null
 */

function smarty_function_file($params, &$smarty){
  
    echo "<input type='file' name='".$params['name']."'/>";

    if($params['value']){
        echo "<br/><a href='http://".$_SERVER['SERVER_NAME']."/".$params['value']."' target='_blank'>view file</a>&nbsp;&nbsp;&nbsp;<a href='/admin/index/deletefile/?m=".$smarty->_tpl_vars['module']."&c=".$smarty->_tpl_vars['controller']."&field=".$params['name']."&backurl=".$_SERVER['REQUEST_URI']."'>delete</a>";
    }
}